/*************************************************
Author: byron
Date: 10/25/2012
Description:
Notes: 
*************************************************/

#ifndef __CSkillMgr_h__
#define __CSkillMgr_h__

#include "CTHashObjectMgr.h"
#include "CSkillEffect.h"
#include "CSkillAffect.h"
#include "CSkill.h"
#include "CSkillCfg.h"

class CSkillMgr
{
public:
    CSkillMgr()
    {

    }

    virtual ~CSkillMgr()
    {

    }

    static int CountSize()
    {
        return CSkillEffCfg::CountSize() + CSkillAffCfg::CountSize() + CSkillCfg::CountSize();
    }

    int Init(const char * sBuff)
    {
        if (!sBuff)
        {
            return RET_SYS_NULL_POINTER;
        }

        int iRet = 0;
        int iOffset = 0;
        
        iRet = _stSkillEffCfg.Init(sBuff + iOffset);
        CT_RETURN(iRet);
        iOffset += CSkillEffCfg::CountSize();

        iRet = _stSkillAffCfg.Init(sBuff + iOffset);
        CT_RETURN(iRet);
        iOffset += CSkillAffCfg::CountSize();

        iRet = _stSkillCfg.Init(sBuff + iOffset);
        CT_RETURN(iRet);

        return 0;
    }

    int LoadConfig(const char* szCfgPath);

    int FindSkillEffCfg(unsigned int uiEffID)
    {
        return _stSkillEffCfg.FindConfig(uiEffID);
    }

    CSkillEffect& GetSkillEffCfg(int iIndex)
    {
        return _stSkillEffCfg.GetConfig(iIndex);
    }

    int FindSkillAffCfg(unsigned int uiAffID)
    {
        return _stSkillAffCfg.FindConfig(uiAffID);
    }

    CSkillAffect& GetSkillAffCfg(int iIndex)
    {
        return _stSkillAffCfg.GetConfig(iIndex);
    }

    int FindSkillCfg(unsigned int uiID)
    {
        return _stSkillCfg.FindConfig(uiID);
    }

    CSkill& GetSkillCfg(int iIndex)
    {
        return _stSkillCfg.GetConfig(iIndex);
    }

    int IsValidSkill(unsigned int uiSkillID, int iSkillType);

    int GetSkillByID(CSkill& stSkill, unsigned int uiSkillID, int iType);

private:
    CSkillEffCfg _stSkillEffCfg;
    CSkillAffCfg _stSkillAffCfg;
    CSkillCfg _stSkillCfg;
};

#endif // __CSkillMgr_h__

